#################################################
############2024 DATASET########################

######################################
### H1: Immigration as Positional Cue
######################################
# Hypothesis 1: Immigration as a Positional Cue
model_h1_2024 <- glm(vote_choice_binary_post ~ immigration_ideology,
                     data = anes_2024,
                     family = binomial(link = "logit"),  na.action = na.exclude)
summary(model_h1_2024)

# Predicted probabilities
library(effects)
plot(allEffects(model_h1_2024), main = "H1: Predicted Vote Choice by Immigration Preferences (2024)")

######################################
### H2: Immigration as Hybrid Valence
######################################

#Hypothesis 2: Immigration as a Hybrid Valence Issue
#Hypothesis 2 (Hybrid valence issue)
model_h2_2024 <- glm(vote_choice_binary_post ~ immigration_ideology + rel_comp + rel_honest,
                     data = anes_2024,
                     family = binomial(link = "logit"))
summary(model_h2_2024)

######################################
### H3: Issue Absorption
######################################

#Hypothesis 3: Immigration × Partisanship Interaction
anes_2024 <- anes_2024 %>%
  mutate(pid_simple = case_when(
    pid %in% c(1,2,3) ~ "Democrat",
    pid == 4 ~ "Independent",
    pid %in% c(5,6,7) ~ "Republican",
    TRUE ~ NA_character_
  )) %>%
  mutate(pid_simple = factor(pid_simple, levels = c("Independent", "Democrat", "Republican")))

model_h3_2024 <- glm(vote_choice_binary_post ~ immigration_ideology + rel_comp + rel_honest + immigration_ideology * pid,
                     data = anes_2024,
                     family = binomial(link = "logit"))
summary(model_h3_2024)

plot(allEffects(model_h3_2024), main = "H3: Immigration Preferences × Partisanship (2024)")